package cn.dida.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.dida.dao.ActivityDao;
import cn.dida.model.Activity;
import cn.dida.model.ActivityPrize;
import cn.dida.model.ActivityRegion;
import cn.dida.model.Pageable;
import cn.dida.model.Product;
import cn.dida.service.ActivityService;
/**
 * <p> 活动管理  业务实现类</p>
 * @author lisha
 * @date 2016-11-14 14:33
 * */
@Service
public class ActivityServiceImpl implements ActivityService {

	@Autowired
	private ActivityDao activityDao;
	
	@Override
	public Pageable<Activity> queryActivity(Integer companyId,String name, String cAdmin,
			Integer sta, String channel, int page) {
		// TODO Auto-generated method stub
		return activityDao.query(companyId,name, cAdmin, sta, channel, page);
	}

	@Transactional
	@Override
	public int insertActivity(Activity activity) {
		// TODO Auto-generated method stub
		return activityDao.insert(activity);
	}
	@Transactional
	@Override
	public Boolean deleteActivity(Integer companyId,int id) {
		// TODO Auto-generated method stub
		return activityDao.delete(companyId,id) == 1;
	}
	@Transactional
	@Override
	public Boolean insertActivityPrize(ActivityPrize aPrize) {
		// TODO Auto-generated method stub
		return activityDao.insertActivityPrize(aPrize) == 1;
	}

	@Override
	public Activity getActivityById(String activityId) {
		// TODO Auto-generated method stub
		return activityDao.getActivityById(activityId);
	}

	/*@Override
	public Integer deleteActivityProduct(int productId) {
		// TODO Auto-generated method stub
		return activityDao.deleteActivityProduct(productId);
	}*/
	@Transactional
	@Override
	public Boolean updateActivity(Integer companyId,Activity activity) {
		// TODO Auto-generated method stub
		return activityDao.update(companyId,activity) == 1;
	}
	
	@Override
	public Boolean usingActivity(String activityId, String type) {
		// TODO Auto-generated method stub
		return activityDao.usingActivity(activityId, type) == 1;
	}

	/*@Override
	public ActivityPrize getActivityPrizeById(String activityId) {
		// TODO Auto-generated method stub
		return activityDao.getActivityPrizeById(activityId);
	}*/

	@Override
	public String getRgnByActivityId(String activityId) {
		// TODO Auto-generated method stub
		return activityDao.getRegionByActivityId(activityId);
	}

	@Override
	public Pageable<ActivityPrize> queryActivityPrize(int page,String activityId) {
		// TODO Auto-generated method stub
		return activityDao.queryActivityPrize(page,activityId);
	}
	@Transactional
	@Override
	public Boolean deleteActivityPrize(Integer activityPrizeId) {
		// TODO Auto-generated method stub
		return activityDao.deleteActivityPrize(activityPrizeId) == 1;
	}
	@Transactional
	@Override
	public Boolean updateActivityAbstract(Activity activity) {
		// TODO Auto-generated method stub
		return activityDao.updateStract(activity) == 1;
	}

	/*@Override
	public Integer delRgnByActivityId(String activityId) {
		// TODO Auto-generated method stub
		return activityDao.delRgnByActivityId(activityId);
	}*/

	@Override
	public List<ActivityRegion> getRgnById(String activityId) {
		// TODO Auto-generated method stub
		return activityDao.getRegionById(activityId);
	}

	@Override
	public Integer delRgnByActivityRegionId(String activityRegionId) {
		// TODO Auto-generated method stub
		return activityDao.delRgnByActivityRegionId(activityRegionId);
	}

	@Override
	public Pageable<Product> querySelected(Integer companyId, String keyword,
			Integer state, int page) {
		// TODO Auto-generated method stub
		return activityDao.querySelected(companyId, keyword, state, page);
	}

	@Override
	public ActivityPrize getActivityPrizeByapId(String activityPrizeId) {
		// TODO Auto-generated method stub
		return activityDao.getActivityPrizeByapId(activityPrizeId);
	}

	@Override
	public List<Activity> queryActivityForExport(Integer companyId,
			String name, Integer sta, String channel) {
		// TODO Auto-generated method stub
		return activityDao.queryForExport(companyId, name, sta, channel);
	}

	@Override
	public Double getTotalOdds(String activityId) {
		// TODO Auto-generated method stub
		return activityDao.getTotalOdds(activityId);
	}

	@Override
	public boolean isExistsActivityPrize(String activityId, String gradeName) {
		// TODO Auto-generated method stub
		return activityDao.isExistsActivityPrize(activityId, gradeName);
	}

	@Override
	public boolean isExistsActivity(String companyId, String name) {
		// TODO Auto-generated method stub
		return activityDao.isExistsActivity(companyId, name);
	}


}
